package com.example.demo.juc.lock;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: xiatian
 * @CreateTime: 2021/10/28 4:54 下午
 * @Description:
 */
public class CountDownLatchTest2 {


    public static void main(String[] args) throws InterruptedException {
        //有2个待处理的时间
        final CountDownLatch latch = new CountDownLatch(2);
        ExecutorService executor = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 2; i++) {
            executor.execute(() -> {
                System.out.println("处理一些事情");
            });

        }
        latch.await();
        executor.shutdown();
        System.out.println("finish");


    }

}
